package com.rbac.web.model.req;

import com.rbac.web.model.PageResult;
import com.rbac.web.model.PageV0;
import com.rbac.web.model.Permission;
import com.rbac.web.model.res.PermissionGetListRes;
import com.rbac.web.service.IPermissionService;
import lombok.*;

import java.util.List;

/**
 * @author gengaoliu
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class PermissionGetListReq extends PageBase {
  public PageResult<PermissionGetListRes> execute(
      PageV0 pageV0, IPermissionService permissionService) {
    PageResult<Permission> all = permissionService.selectPage(pageV0);
    List<PermissionGetListRes> list =
        all.getList().stream().map(PermissionGetListRes::from).toList();
    return PageResult.of(all.getPage(), all.getSize(), all.getTotal(), list);
  }
}
